<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>诚度科技导航</title>
	<!-- 	引入外部css样式-->
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/bootstrap.min.css" >
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/font-awesome/css/font-awesome.css" >
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/animate.css">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/admin-style.css">
	<!-- 引入外部jQuery插件-->
	<script src="__PUBLIC__/js/jquery-2.1.1.min.js"></script>
	<!-- 引入外部layer弹层插件-->
	<script src="__PUBLIC__/static/layer/layer.js"></script>
</head>

<body class="gray-bg">

	<div class="middle-box text-center loginscreen animated fadeInDown">
		<div>
			<div>
				<h1 class="logo-name">CD</h1>
			</div>
			<h3>欢迎使用诚度后台</h3>
			<form id="form" name="form" method="post" action="{:U('checkLogin')}" autocomplete="off">
				<div class="form-group">
					<input type="text" name="username" class="form-control" placeholder="用户名">
				</div>
				<div class="form-group">
					<input type="password" name="password" class="form-control" placeholder="密码">
				</div>
				<!--生成验证码开始-->
				<div class="form-group login">
					<span>验证码</span>
					<input name="code" style="width:110px" type="text" id="code"/>
					<a>
						<img class=" reloadverify "  src="{:U('Admin/Public/verify')}"
						id="imgcode" Onclick="this.src=this.src+'?'+Math.random()"/>
					</a>
				</div>
				<!--生成验证码开始-->			
				<button type="submit" class="btn btn-primary block full-width m-b">登 录</button>
			</form>
		</div>		
	</div>
<!--ajax异步提交开始-->
<script>
    $('form').submit(function(){
        //获取用户名
        var username  = $("input[name='username']").val();
        //获取密码
        var password  = $("input[name='password']").val();
        //获取验证码
        var code = $("#code").val();
        //判断用户名、密码、验证码是否为空
        if(!username){
            layer.msg('用户名不能为空！',{time:2000});
            return false;
        }
        if(!password){
            layer.msg('密码不能为空！',{time:2000});
            return false;
        }
        if(!code){
            layer.msg('验证码不能为空！',{time:2000});
            return false;
        }
        //获取跳转路径也就是action的值。
        var url  = $(this).attr('action');
        $.ajax({
            type:"post",	//post请求
            url :url,      //发送请求的地址，这里是checkLogin方法
            data:{username:username,password:password,code:code},	//传递的参数
            success: function(res){	//回调函数，res参数是从checkLoin方法返回的值
                if(res.status){
                    layer.msg(res.message,{time:1000},function(){
                        window.location.href = "{:U('Index/index')}";
                    });
                }else{
                    //刷新验证码
                    $(".reloadverify").click();
                    layer.msg(res.message,{time:2000});
                }
            }
        });
        return false;
    });
</script>
<!-- ajax异步提交结束 -->
</body>
</html>